<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const arr = [1,2,3,4,[1,3,4,6],[2,5,[6,7]]];
        function flatArray(arr)
        {
            let result = [];
            arr.forEach((item)=>{
              if(Array.isArray(item))
              {
                   result.push(...flatArray(item))
              }
              else
              {
                 result.push(item);
              }
            })

            return result;
        }
        
        let newArry = flatArray(arr);
        console.log(newArry);

    </script>
</body>
</html>